﻿// --- Copyright (c) 2010 Steven Hartgers ---
// Copyright (C) 2010 Steven Hartgers All rights are reserved.
// Author contact: fiinix00/at\gmail.com
// ------------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify 
// it under the terms of the GNU General Public License as published by 
// the Free Software Foundation, either version 3 of the License, or 
// (at your option) any later version. 
//  
// This program is distributed in the hope that it will be useful, 
// but WITHOUT ANY WARRANTY; without even the implied warranty of 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
// GNU General Public License for more detail
//  
// You should have received a copy of the GNU General Public License 
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// ------------------------------------------------------------------------
// COPYRIGHT NOTICE: This copyright notice may NOT be removed, obscured or modified 
// without written consent from the author.
// --- End copyright notice --- 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Hack.Extensions;

namespace Hack.Converters.Fun
{
    /// <summary>
    /// http://www.elfqrin.com/lamerize.html 
    /// 
    /// Javascript -> C#
    /// </summary>
    public static class _1337Speek
    {
        public static readonly string[] PhrasesEnglish = 
        { 
            "crap", "dude", "hacker",
            "hacks", "you", "cool", "oh my god",
            "fear", "power", "own",
            "what the hell", "elite", "for the win",
            "oh really", "good game"
        };
        public static readonly string[] PhrasesLeet =
        {
            "carp", "dood", "haxor", "hax", "joo",
            "kewl", "omg", "ph43", "powwah", "pwn", 
            "wth", "leet", "ftw", "o rly", "gg"
        };
        public static readonly string[] LettersEnglish =
        {
            "n", "b", "k", "d", "e", "f", "g", "h",
            "p", "m", "r", "l", "o", "q", "s", "t",
            "u", "x", "w", "y", "z", "c", "a", "j", 
            "i", "v", " "
        };

        public static readonly string[] LettersLeet = 
        {

            "/\\/", "|}", "|X", "[)", "3", "|=", "gee", "|-|",
            "|*", "(\\/)", "|2", "1", "()", "0", "$", "+",
            "|_|", "><", "\\X/", "\"/", "2", "<", "/\\", "_|", 
            "|", "\\/", "  "
            
        };
        public static string To1337Speek(this string value)
        {
            string worker = value;
            for (int i = 0; i < PhrasesEnglish.Length; ++i)
            {
                worker = worker.Replace(PhrasesEnglish[i], PhrasesLeet[i]);
            }
            for (int i = 0; i < LettersEnglish.Length; ++i)
            {
                worker = worker.Replace(LettersEnglish[i], LettersLeet[i]);
            }

            return value = worker;
        }
        public static string ToNormalSpeek(this string value)
        {
            string worker = value;
            for (int i = 0; i < PhrasesEnglish.Length; ++i)
            {
                worker = worker.Replace(PhrasesLeet[i], PhrasesEnglish[i]);
            }
            for (int i = 0; i < LettersEnglish.Length; ++i)
            {
                worker = worker.Replace(LettersLeet[i], LettersEnglish[i]);
            }

            return value = worker;
        }

        public static string _1337(
            this string value,
            _1337LanguageStyle langStyle, 
            _1337CaseStyle caseStyle, 
            _1337LameStyle lameStyle, 
            bool reverse)
        {
            string worker = value;


// ReSharper disable ConvertToConstant.Local
// ReSharper disable InconsistentNaming
            string _lameStyleNone_LOW = "abcdefghijklmnopqrstuvwxyz";

            string _lameStyleNone_HIGH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            string _lameStylelmdos_LOW = "†b€dˆfghŒjklm¤¢pqrõt—vwx˜z";
            string _lameStylelmdos_HIGH = "„B‡ÑŸGHJK£M¥0PQR$TšVWXíZ";

            string _lameStylelmwin_LOW = "âbçdëfghíjklmñôpq®$túvwxýz";
            string _lameStylelmwin_HIGH = "ÃßÇÐÊFGHÎJK£MÑÖþQR§TÛVW×ÝZ";
// ReSharper restore InconsistentNaming
// ReSharper restore ConvertToConstant.Local
            Func<string, string> goAlphabet = (alphabet) =>
            {
                for (int i = 0; i < worker.Length; i++)
                {
                    int _charIndex = _lameStyleNone_LOW.IndexOf(worker[i]);

                    if (!_charIndex.Equals(-1))
                    {
                        worker = worker.Replace(_lameStyleNone_LOW.Substring(_charIndex, 1)[0], alphabet.Substring(_charIndex, 1)[0]);
                    }
                }
                return worker;
            };
            Func<string[][], string> goArrayArray = (array) =>
                {
                    for (int a = 0; a < 1; a++)
                    {
                        for (int b = 0; b < array.Length; b++)
                        {
                            worker = worker.Replace(array[b][0], array[b][1]);
                        }
                    }
                    return worker;
                };
            string[][] warezDoodz = 
            { 
                #region
new[] {" the "," da " },
new[] {" my "," ma " },
new[] {"this","dis" },
new[] {"want to","wanna" },
new[] {"going to","gonna" },
new[] {"got to","gotta" },
new[] {"got you","gotcha" },
new[] {"what to","whatta" },
new[] {"what are you","watcha" },
new[] {"cup of","cuppa" },
new[] {"a lot of","lotsa" },
new[] {"through","thru" },
new[] {"though","tho" },
new[] {"that's","ait's" },
new[] {"don't know","dunno" },
new[] {"that is","ait's" },
new[] {"that's","ait's" },
new[] {"by the way","BTW" },
new[] {"what da f**k","WTF" },
new[] {"what da hell","WTH" },
new[] {"cool","kewl" },
new[] {"extremely ","k-" },
new[] {"see you","Cya" },
new[] {"every","evry" },
new[] {"body","budy" },
new[] {"love","luv" },
new[] {" old "," ol'" },
new[] {"about","bout" },
new[] {"second","sec" },
new[] {"minute","min" },
new[] {"cker","xor" },
new[] {"elite","leet" },
new[] {"money","$$$" },
new[] {"compuserve","compu$erve" },
new[] {"microsoft","micro$oft" },
new[] {"windows","windooze" },
new[] {"internet explorer","internet exploDer" },
new[] {"energy","nrg" },
new[] {"with","w/" },
new[] {"w/out","w/o" },
new[] {"tal ","tull " },
new[] {"tter","ttr" },
new[] {"ca","ka" },
new[] {"co","ko" },
new[] {"cu","ku" },
new[] {"ck","k" },
new[] {"es","ez" },
new[] {"kan","can" },
new[] {"kause","cuz" },
new[] {"kos ","cuz " },
new[] {"becuz","cuz" },
new[] {"porn","pron" },
new[] {"chikago","Sheecago" },
new[] {"loser","luzer" },
new[] {"ser","zer" },
new[] {"swer","zwer" },
new[] {"i am","Im" },
new[] {"we are","were" },
new[] {"we're","were" },
new[] {"they are","theyr" },
new[] {"it's not","ain't" },
new[] {"barbecue","bbq" },
new[] {"your","joor" },
new[] {"you","U" },
new[] {"are","R" },
new[] {"ing ","in' " },
new[] {"oode","ood" },
new[] {"ight","ite" },
new[] {"qui","kwi" },
new[] {"ea","ee" },
new[] {"ks","x" },
new[] {"zs","ss" },
new[] {"ff","f" },
new[] {"fa","pha" },
new[] {"fe","phe" },
new[] {"fi","phi" },
new[] {"fo","pho" },
new[] {"fr","phr" },
new[] {"phreek","phreak" },
new[] {"phone","fone" },
//new[] {" oph "," of " },
//new[] {" iph "," if " },
#endregion
            };
            string[][] c6Itallian =
            {
                #region
new[] {"ci sei","C6" },
new[] {"uno","1" },
new[] {"due","2" },
new[] {"tre","3" },
new[] {"quattro","4" },
new[] {"cinque","5" },
new[] {"sei","6" },
new[] {"sette","7" },
new[] {"otto","8" },
new[] {"nove","9" },
new[] {"zero","0" },
new[] {" un "," 1 " },
new[] {" ci "," C " },
new[] {"per","x" },
#endregion
            };
            string[][] okkupato =
            {
                #region
new string[] {"chi","ki" },
new string[] {"che","ke" },
new string[] {"cca","kka" },
new string[] {"cco","kko" },
new string[] {"ccu","kku" },
new string[] {"ca","ka" },
new string[] {"co","ko" },
new string[] {"cu","ku" },
new string[] {"q","k" },
new string[] {"ss","x" },
new string[] {" non "," nn " }
#endregion
            };
            switch (langStyle)
            {
                case _1337LanguageStyle.None: break;
                case _1337LanguageStyle.Warez_d00dz__English:
                    goArrayArray(warezDoodz); break;
                case _1337LanguageStyle.C6__Italian:
                    goArrayArray(c6Itallian); break;
                case _1337LanguageStyle.Okkupato:
                    goArrayArray(okkupato); break;
                default: break;
            }
            switch (lameStyle)
            {
                case _1337LameStyle.None: break;
                case _1337LameStyle.MessyDosFamerz:
                    goAlphabet(_lameStylelmdos_LOW);
                    break;
                case _1337LameStyle.WindoozeFamerz:
                    goAlphabet(_lameStylelmwin_LOW);
                    break;
                case _1337LameStyle._1337:
                    worker = worker.To1337Speek();
                    break;
            }
            switch (caseStyle)
            {
                case _1337CaseStyle.Untouched: break;
                case _1337CaseStyle.all_lower_case:
                    worker.ToLower(); break;
                case _1337CaseStyle.ALL_UPPER_CASE:
                    worker.ToUpper(); break;
                case _1337CaseStyle.UpperCamerCase:
                    worker.ToUpperCamerCase(); break;
                case _1337CaseStyle.LowerCamerCase:
                    worker.ToLowerCamerCase(); break;
                case _1337CaseStyle.CapitalizeFirst:
                    worker.ToTitleCase(); break;
                case _1337CaseStyle.decapitalizeFirst:
                    worker.DecapitalizeFirst(); break;
            }
            if (reverse)
            {
                worker = worker.Reverse();
            }
            return value = worker;
        }

        public enum _1337LameStyle
        {
            None,
            MessyDosFamerz,
            WindoozeFamerz,
            _1337
        }
        public enum _1337CaseStyle
        {
            Untouched,
            all_lower_case,
            ALL_UPPER_CASE,
            LowerCamerCase,
            UpperCamerCase,
            CapitalizeFirst,
            decapitalizeFirst
            //iNVERTED,
            //AlTeRnAtE_1,
            //aLtErNaTe_2,
            //ElItE,
            //aNTieLiTe,
            //RanDOM,
        }
        public enum _1337LanguageStyle
        {
            None,
            Warez_d00dz__English,
            Okkupato,
            C6__Italian
        }
    }
}
